package com.gdou.login.service.impl;

import com.gdou.login.dao.UserRepository;
import com.gdou.login.dataobject.User;
import com.gdou.login.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ProjectName: login
 * @Package: com.gdou.login.service.impl
 * @ClassName: userService
 * @Author: carrymaniac
 * @Description:
 * @Date: 2020/3/3 2:44 下午
 * @Version:
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserRepository userRepository;
    @Override
    public User register(User user) {
        User save = userRepository.save(user);
        return save;
    }

    @Override
    public int login(String userNumber, String password) {
        User userByUserNumber = userRepository.findUserByUserNumber(userNumber);
        if(userByUserNumber==null||!userByUserNumber.getPassword().equals(password)){
            return 0;
        }else {
            return 1;
        }
    }
}
